import axios from 'axios'

// 后端接口地址
const backHost = 'http://127.0.0.1:8888'

// 登录
export const login = params => { return axios.post(`${backHost}/user/login/`, params) }
// 注册
export const register = params => { return axios.post(`${backHost}/user/register/`, params) }
// // 检查邮箱是否已注册
// export const repeatEmail = email => { return axios.get(`${backHost}/user/${email}/count/`) }
// 检查账号是否已注册
export const repeatUsername = username => { return axios.get(`${backHost}/user/${username}/count/`) }
// 获取导航栏
export const getNavs = () => { return axios.get(`${backHost}/nav/`) }
// 获取概要
export const getSummary = () => { return axios.get(`${backHost}/summary/`) }
// 获取环境列表
export const getEnvironments = params => { return axios.get(`${backHost}/basic/environment/`, { params: params }) }
// 获取环境名称列表
export const getEnvironmentNames = () => { return axios.get(`${backHost}/basic/environment/names/`) }
// 新建环境
export const createEnvironment = params => { return axios.post(`${backHost}/basic/environment/`, params) }
// 编辑环境
export const editEnvironment = (id, params) => { return axios.put(`${backHost}/basic/environment/${id}/`, params) }
// 删除环境
export const deleteEnvironment = id => { return axios.delete(`${backHost}/basic/environment/${id}/`) }
// 获取项目列表
export const getProjects = params => { return axios.get(`${backHost}/api/project/`, { params: params }) }
// 获取项目下测试用例名称列表
export const getProjectAndInterfaceNames = () => { return axios.get(`${backHost}/api/project/cases/`) }
// 新建项目
export const createProject = params => { return axios.post(`${backHost}/api/project/`, params) }
// 编辑项目
export const editProject = (id, params) => { return axios.put(`${backHost}/api/project/${id}/`, params) }
// 删除项目
export const deleteProject = id => { return axios.delete(`${backHost}/api/project/${id}/`) }
// 运行项目
export const runProject = (id, params) => { return axios.post(`${backHost}/api/project/${id}/run/`, params) }
// 获取接口列表
export const getInterfaces = params => { return axios.get(`${backHost}/api/interface/`, { params: params }) }
// 新建接口
export const createInterface = params => { return axios.post(`${backHost}/api/interface/`, params) }
// 编辑接口
export const editInterface = (id, params) => { return axios.put(`${backHost}/api/interface/${id}/`, params) }
// 删除接口
export const deleteInterface = id => { return axios.delete(`${backHost}/api/interface/${id}/`) }
// 运行接口
export const runInterface = (id, params) => { return axios.post(`${backHost}/api/interface/${id}/run/`, params) }
// 获取辅助函数文件列表
export const getFunctions = params => { return axios.get(`${backHost}/api/function/`, { params: params }) }
// 新建辅助函数文件
export const createFunction = params => { return axios.post(`${backHost}/api/function/`, params) }
// 编辑辅助函数文件
export const editFunction = (id, params) => { return axios.put(`${backHost}/api/function/${id}/`, params) }
// 删除辅助函数文件
export const deleteFunction = id => { return axios.delete(`${backHost}/api/function/${id}/`) }
// 获取公共配置列表
export const getConfigs = params => { return axios.get(`${backHost}/api/config/`, { params: params }) }
// 新建公共配置
export const createConfig = params => { return axios.post(`${backHost}/api/config/`, params) }
// 编辑公共配置
export const editConfig = (id, params) => { return axios.put(`${backHost}/api/config/${id}/`, params) }
// 删除公共配置
export const deleteConfig = id => { return axios.delete(`${backHost}/api/config/${id}/`) }
// 获取项目下公共配置名称列表
export const getProjectAndInterfaceAndConfigNames = () => { return axios.get(`${backHost}/api/project/configs/`) }
// 获取测试用例列表
export const getTestCases = params => { return axios.get(`${backHost}/api/testcase/`, { params: params }) }
// 新建测试用例
export const createTestCase = params => { return axios.post(`${backHost}/api/testcase/`, params) }
// 编辑测试用例
export const editTestCase = (id, params) => { return axios.put(`${backHost}/api/testcase/${id}/`, params) }
// 删除测试用例
export const deleteTestCase = id => { return axios.delete(`${backHost}/api/testcase/${id}/`) }
// 运行测试用例
export const runTestCase = (id, params) => { return axios.post(`${backHost}/api/testcase/${id}/run/`, params) }
// 获取测试报告列表
export const getReports = params => { return axios.get(`${backHost}/product/report/`, { params: params }) }
// 获取测试报告详情
export const getReportHtml = id => { return axios.get(`${backHost}/product/report/${id}/`) }
// 下载报告
export const downloadReportHtml = id => { return axios.get(`${backHost}/product/report/${id}/download/`) }
// 获取测试套件列表
export const getTestSuites = params => { return axios.get(`${backHost}/api/suite/`, { params: params }) }
// 新建测试套件
export const createTestSuite = params => { return axios.post(`${backHost}/api/suite/`, params) }
// 编辑测试套件
export const editTestSuite = (id, params) => { return axios.put(`${backHost}/api/suite/${id}/`, params) }
// 删除测试套件
export const deleteTestSuite = id => { return axios.delete(`${backHost}/api/suite/${id}/`) }
// 运行测试套件
export const runTestSuite = (id, params) => { return axios.post(`${backHost}/api/suite/${id}/run/`, params) }
// 获取当前用户信息
export const getUserInfo = id => { return axios.get(`${backHost}/user/${id}/`) }
// 更新当前用户信息
export const editUserInfo = (id, params) => { return axios.put(`${backHost}/user/${id}/`, params) }
// 获取用户列表
export const getUsers = params => { return axios.get(`${backHost}/user/list/`, { params: params }) }
// 更新当前用户密码
export const editUserPassword = (id, params) => { return axios.put(`${backHost}/user/${id}/password/`, params) }
